package com.ym.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.ym.web.model.Users;
import com.ym.web.service.UsersService;
import com.ym.web.util.Page;

@Controller
@RequestMapping("user")
public class UsersController{
	

	
	  @Autowired
	  private UsersService usersService;
	  
	  @RequestMapping(value="/list")
	  public String listUsers( @RequestParam(value = "pageNo", required = false,defaultValue="1") 
	     int pageNo,Long id,String userName,Model model){
		  Page page=new Page();
		  //前台传递页码
		  page.setPageNo(pageNo);
		  //map封装查询参数
		  Map<String,Object> params=new HashMap<String,Object>(); 
		  
		  params.put("id",id);
		  params.put("userName",userName);
		  page.setParams(params);
		  //获得条件查询的分页数据
		  List<Users> userList= usersService.queryListbyPage(page);
		  page.setResults(userList);
		  model.addAttribute("page", page);
		  return "users_info_list";
		  
	  }

}
